/* GUI CONVERTED from rsplqty.p (converter v1.75) Sat Aug 12 23:14:26 2000 */
/* rsplqty.p - Release Management Customer Schedules                    */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/*F0PN*/ /*V8:ConvertMode=Maintenance                                   */
/*J2DG*/ /*V8:RunMode=Character,Windows                                 */
/* REVISION: 7.2    LAST MODIFIED: 02/14/95           BY: WUG *G0F7*    */
/* REVISION: 9.0    LAST MODIFIED: 04/16/99           BY: *J2DG* Reetu Kapoor*/
/* REVISION: 9.1    LAST MODIFIED: 08/12/00           BY: *N0KP* myb         */


/*J2DG*/ /* GROUPED MULTIPLE FIELD ASSIGNMENTS INTO ONE AND ADDED NO-UNDO */
/*J2DG*/ /* WHEREVER MISSING AND REPLACED FIND STATEMENTS WITH FOR FIRST  */
/*J2DG*/ /* STATEMENTS FOR ORACLE PERFORMANCE.                            */
/*
CALCULATES QTY TO USE TO LOOK UP A PRICE FROM A  PRICE  LIST  FOR
SCHEDULED  PURCHASE  ORDERS.
*/

define input parameter pod_recid   as recid   no-undo.
define input parameter receipt_qty as decimal no-undo.
define output parameter  price_qty as decimal no-undo.

define variable supplier_schedule as integer initial 4 no-undo.
define variable cum_rcvd_qty      as decimal no-undo.

/*J2DG** find pod_det where recid(pod_det) = pod_recid no-lock. */
/*J2DG*/ for first pod_det
/*J2DG*/    fields (pod_cum_qty pod_curr_rlse_id pod_line pod_nbr)
/*J2DG*/    where recid(pod_det) = pod_recid no-lock:
/*J2DG*/ end. /* FOR FIRST POD_DET */

if receipt_qty >= 0 then do:
/*J2DG*/ assign
            price_qty    = receipt_qty
            cum_rcvd_qty = pod_cum_qty[1].
end.
else do:
/*J2DG*/ assign
            price_qty    = - receipt_qty
            cum_rcvd_qty = pod_cum_qty[1] + receipt_qty.
end.

/*J2DG** BEGIN DELETE **
 * find sch_mstr
 * where sch_type = supplier_schedule
 * and sch_nbr = pod_nbr
 * and sch_line = pod_line
 * and sch_rlse_id = pod_curr_rlse_id[supplier_schedule - 3]
 * no-lock no-error.
 *J2DG** END DELETE **/

/*J2DG*/ for first sch_mstr
/*J2DG*/    fields (sch_line sch_nbr sch_pcr_qty sch_rlse_id sch_type)
/*J2DG*/    where sch_type = supplier_schedule
/*J2DG*/      and sch_nbr  = pod_nbr
/*J2DG*/      and sch_line = pod_line
/*J2DG*/      and sch_rlse_id = pod_curr_rlse_id[supplier_schedule - 3]
/*J2DG*/    no-lock:
/*J2DG*/ end. /* FOR FIRST SCH_MSTR */

if not available sch_mstr then leave.
if cum_rcvd_qty < sch_pcr_qty then leave.

/*J2DG** BEGIN DELETE **
 * find first schd_det
 * where schd_type = sch_type
 * and schd_nbr = sch_nbr
 * and schd_line = sch_line
 * and schd_rlse_id = sch_rlse_id
 * and schd_cum_qty > cum_rcvd_qty
 * no-lock no-error.
 *J2DG** END DELETE **/

/*J2DG*/ for first schd_det
/*J2DG*/    fields (schd_cum_qty schd_discr_qty schd_line schd_nbr
/*J2DG*/            schd_rlse_id schd_type)
/*J2DG*/    where schd_type    = sch_type
/*J2DG*/      and schd_nbr     = sch_nbr
/*J2DG*/      and schd_line    = sch_line
/*J2DG*/      and schd_rlse_id = sch_rlse_id
/*J2DG*/      and schd_cum_qty > cum_rcvd_qty no-lock:
/*J2DG*/ end. /* FOR FIRST SCHD_DET */

if available schd_det then do:
   price_qty = schd_discr_qty.
end.
